<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>京东秒杀倒计时</title>
    <style>
        *{
            margin: 0;
            padding: 0;
        }
        #box{
            width: 200px;height: 300px;margin: 200px 200px;
            background-image: url(/tu.png);
            position: relative;
        }
        .txt{
            width: 150px;height: 50px;
            text-align: center;
            line-height: 50px;
            color: #fff;
            font-size: 30px;
            font-weight: 900px;
            position: absolute;
            left: 25px;
            top: 50px;
        }
        .hour{
            left: 20px;
        }
        .hm{
            left: 68px;
        }
        .minute{
            left: 80px;
        }
        .ms{
            right: 68px;
        }
        .second{
            left: 140px;
        }
        .hour,.minute,.second{
            position: absolute;
            top: 200px;
            color: #fff;
            font-weight: 800;
            font-size: 20px;
            text-align: center;
            line-height: 40px;
            width: 40px;
            height: 40px;
            background: black;

        }
        .hm,.ms{
            color: #fff;
            font-size: 20px;
            font-weight: 900;
            position: absolute;
            bottom: 70px;
        }
        .words{
            margin-top: 160px;
            font-size: 18px;
            color:#fff;
            margin-left: 20px;
            text-align: center;
            position: absolute;

        }
    </style>
</head>
<body>
    <div id="box">
       <div class="txt">京东秒杀</div> 
       <div class="words"><strong>16:00</strong> 点场 倒计时</div>
       <div class="hour"></div>
       <span class="hm">:</span>
       <div class="minute"></div>
       <span class="ms">:</span>
       <div class="second"></div>
    </div>
    <script>
        var hour=document.querySelector(".hour")
        var minute=document.querySelector(".minute")
        var second=document.querySelector(".second")
        var inputTime = +new Date("2021-06-10 18:00:00")
        countDown();
        setInterval(countDown,1000);
        function countDown(){
            var nowTime = +new Date()
            var times = (inputTime - nowTime) / 1000
            var h = parseInt(times / 60 / 60 % 24)
            h = h < 10 ? '0' + h : h;
            hour.innerHTML=h
            var m = parseInt(times / 60 % 60)
            m = m < 10 ? '0' + m : m;
            minute.innerHTML=m
            var s = parseInt(times % 60)
            s = s < 10 ? '0' + s : s;
            second.innerHTML=s
        }
    </script>
</body>

</html>